<?php

namespace App\Http\Middleware;

use Closure;

use Auth;

class AdminMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
//        验证用户是否已登录，若没有则跳转回登录页面
        if ( ! Auth::guard('admin')->check()){
            return redirect('/admin/login');
        }

        return $next($request);
    }
}
